package org.fang.controller;

import org.fang.common.PlatformResult;
import org.fang.pojo.CloudUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class RibbonConsumerController {
    @Autowired
    RestTemplate restTemplate;
    public static final String URL_PREFIX = "http://CLOUD-PROVIDER";

    @RequestMapping("/consumer/ribbon/cloudUser/add")
    public PlatformResult add(@RequestBody CloudUser user) {
        return restTemplate.postForObject(URL_PREFIX + "/cloudUser/add", user, PlatformResult.class);
    }
    @RequestMapping("/consumer/ribbon/cloudUser/queryById/{id}")
    public PlatformResult queryById(@PathVariable("id") String id) {
        return restTemplate.postForObject(URL_PREFIX + "/cloudUser/queryById/" + id,null, PlatformResult.class);
    }
}
